require "RMagick"

sql=File.open("/root/update_wh.sql",'w')

Dir.glob("/root/photo/*/*.jpg") do |f|
	
	puts f
	img=Magick::Image.read(f).first	

	h=195*img.rows/img.columns
	puts "w:#{img.columns},h:#{img.rows},thumb_h:#{h}"
	sql.puts "update photo set thumb_height=#{h} where name='#{f[f.rindex("/")+1,f.length-1]}';"

	img.destroy!

end

sql.close
